#define _CRT_SECURE_NO_WARNINGS 1
#pragma once
#include <iostream>
#include <assert.h>
using namespace std;
namespace zrc
{
	class string
	{
	public:
		typedef char* iterator;
		typedef const char* const_iterator;

		//string();
		iterator begin();
		iterator end();
		const_iterator begin() const;
		const_iterator end() const;
		string(const char* str="");
		string(const string& s);
		string( string&& s);
		//string(const string& s);
		~string();

		const char* c_str() const;

		size_t size() const;
		size_t capacity() const;
		char& operator[](size_t pos);
		const char& operator[](size_t pos) const;
		void reserve(size_t n);
		void push_back(char ch);
		//void append(string& str);
		void append(const char *s);

		string& operator+=(char ch);
		string& operator+=(const char * str);

		void insert(size_t pos, char ch);
		void insert(size_t pos, const char * str);
		void erase(size_t pos=0, size_t len=npos);
		size_t find(char ch, size_t pos = 0);
		size_t find(const char* str, size_t pos = 0);

		void swap(string& s);
		string substr(size_t pos = 0, size_t len = npos);

		bool operator<(const string& s) const;
		bool operator>(const string& s) const;
		bool operator<=(const string& s) const;
		bool operator>=(const string& s) const;
		bool operator==(const string& s) const;
		bool operator!=(const string& s) const;
		//string& operator=(string tmp) ;
		string& operator=(string& tmp);
		string operator=(string &&str) ;
		void clear();
	private:
		char* _str=nullptr;
		size_t _size=0;
		size_t _capacity=0;
		const static size_t npos;
	};
	istream& operator>> (istream& is, string& str);
	ostream& operator<< (ostream& os, const string& str);
}
